package star.trek.voyager.module.benz.axletree_amg;

import org.jiopi.framework.annotation.module.RegisterModule;
import org.jiopi.framework.annotation.module.Instantiation;
import star.trek.voyager.blueprint.axletree.Axletree;
import star.trek.voyager.blueprint.status.Status;
import star.trek.voyager.blueprint.wheel.Wheel;

@RegisterModule
@Instantiation(initMethod="init")
public class AMGAxletree implements Axletree , Status {
	
	private String status = "not inited";
	
	private int wheelNum = 0;
	
	private Wheel[] wheels = new Wheel[4];
	
	public void init(){
		StringBuilder sb = new StringBuilder();
		for(Wheel wheel:wheels){
			if(wheel!=null){
				wheelNum++;
				sb.append(wheel.getInfo()).append("\n");
			}
		}
		status = sb.toString();
		//System.out.println("AMGAxletree init : "+status+" ======over");
	}

	public void socket(Wheel wheel, String ID) {
		int wheelID = Integer.parseInt(ID);
		this.wheels[wheelID] = wheel;
		//System.out.println("AMGAxletree socket Wheel "+ID+" "+wheel);
	}

	public String checkStatus() {
		//System.out.println("AMGAxletree checkStatus "+wheelNum);
		return "====AMGAxletree status====\nwheel num :"+wheelNum+"\n"+status+"====over====\n\n";
	}
	
	@Override
	public String toString(){
		return this.getClass().getName()+"-0.1.0.0";
	}

}
